//
//  LoginViewController.m
//  day1
//
//  Created by 于跃隆 on 2020/4/5.
//  Copyright © 2020 于跃隆. All rights reserved.
//

#import "LoginViewController.h"
#import "LoginNumberViewController.h"
#import "phoenDViewController.h"
#import "IosLogionViewController.h"
#import "XyViewController.h"
#import "YSViewController.h"
#import "MyViewController.h"

@interface LoginViewController (){
    //导航文字
    UILabel *navtitle;
}

@end

@implementation LoginViewController


-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    
//    self.navigationController.navigationBar.hidden = YES;
    
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    //245 246 251
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:246/255.0 blue:251/255.0 alpha:1.0];
    
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"backButton"] style:UIBarButtonItemStylePlain target:self action:@selector(BackClick)];
//    self.navigationItem.title = @"登录";
    
    
    //设置导航条颜色
    UIView *Jbview = [[UIView alloc] init];
    Jbview.userInteractionEnabled = YES;
//    Jbview.frame = CGRectMake(0,KSCHEIGHT(-37),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(75));

    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,KSCHEIGHT(0),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(85));
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
    gl.locations = @[@(0.0),@(1.0)];
    [Jbview.layer addSublayer:gl];
    
    [self.navigationController.navigationBar addSubview:Jbview];
    
    //返回button
    UIButton *backBtn = [[UIButton alloc] init];
    [backBtn setBackgroundImage:[UIImage imageNamed:@"backButton"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(BackClick) forControlEvents:UIControlEventTouchUpInside];
    [Jbview addSubview:backBtn];
    
    //标题文字
    navtitle = [[UILabel alloc] init];
    navtitle.text = @"登录";
    navtitle.textColor = [UIColor whiteColor];
    navtitle.font = kFONT(18);
    [Jbview addSubview:navtitle];
    
    [Jbview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(KSCHEIGHT(-37));
        make.width.mas_equalTo(kSCRATIO(self.view.frame.size.width));
        make.height.mas_equalTo(KSCHEIGHT(85));
    }];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Jbview.mas_left).mas_equalTo(kSCRATIO(20));
        make.bottom.mas_equalTo(Jbview.bottom).mas_equalTo(KSCHEIGHT(-15));
        make.width.mas_equalTo(kSCRATIO(10));
        make.height.mas_equalTo(KSCHEIGHT(18));
    }];
    [navtitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(Jbview);
        make.bottom.mas_equalTo(Jbview.bottom).mas_equalTo(KSCHEIGHT(-15));
        
    }];
    
    
    
    
    
    
    

    
    
    [self setControlFrame];
    
    
}
-(void)BackClick{
    
//    MyViewController *myV = [[MyViewController alloc] init];
    [[AppDelegate shareAppDelegate] setTabbarViewController];
//    [self.navigationController pushViewController:myV animated:NO];
//    [self.navigationController popToViewController:myV animated:YES];
//    [self.navigationController popViewControllerAnimated:YES];
//    [self.navigationController popToRootViewControllerAnimated:YES];
}
-(void)setControlFrame{
    
    //头iamgeV
    UIImageView *TouImageV = [[UIImageView alloc] init];
//    TouImageV.frame = CGRectMake(130,144,115,115);
    TouImageV.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    TouImageV.layer.shadowColor = [UIColor colorWithRed:173/255.0 green:172/255.0 blue:172/255.0 alpha:0.14].CGColor;
    TouImageV.layer.shadowOffset = CGSizeMake(0,2);
    TouImageV.layer.shadowOpacity = 1;
    TouImageV.layer.shadowRadius = 4;
    ViewRadius(TouImageV, KSCHEIGHT(57.5));
    [self.view addSubview:TouImageV];
    
    //介绍label
    UILabel *jslabel = [[UILabel alloc] init];
    jslabel.frame = CGRectMake(114.5,282.5,146,17);
    jslabel.numberOfLines = 0;
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"趣味多多 赚钱多多" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(18)],NSForegroundColorAttributeName: [UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]}];
    jslabel.attributedText = string;
    [self.view addSubview:jslabel];
    
    //手机号登录btn
    UILabel *Nmuberlabel = [[UILabel alloc] init];
    Nmuberlabel.numberOfLines = 0;

    NSMutableAttributedString *numberstring = [[NSMutableAttributedString alloc] initWithString:@"手机号登录" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: KSCHEIGHT(15)],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];

    Nmuberlabel.attributedText = numberstring;
    
    UIButton *NumberBtn = [[UIButton alloc] init];
    NumberBtn.backgroundColor = [UIColor colorWithRed:172/255.0 green:95/255.0 blue:251/255.0 alpha:1.0];
    NumberBtn.layer.shadowColor = [UIColor colorWithRed:173/255.0 green:172/255.0 blue:172/255.0 alpha:0.14].CGColor;
    NumberBtn.layer.shadowOffset = CGSizeMake(0,2);
    NumberBtn.layer.shadowOpacity = 1;
    NumberBtn.layer.shadowRadius = 4;

    [NumberBtn addTarget:self action:@selector(numberBClick) forControlEvents:UIControlEventTouchUpInside];
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,0,kSCRATIO(250),KSCHEIGHT(40));
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
    gl.locations = @[@(0.0),@(1.0)];
    ViewRadius(NumberBtn, KSCHEIGHT(20));

    [NumberBtn.layer addSublayer:gl];
    [NumberBtn addSubview:Nmuberlabel];
    [self.view addSubview:NumberBtn];
    
    //iOS账号登录
//    UILabel *iosZHlabel = [[UILabel alloc] init];
//    iosZHlabel.frame = CGRectMake(150,372,75,14);
//    iosZHlabel.numberOfLines = 0;
//
//    NSMutableAttributedString *iosZhstring = [[NSMutableAttributedString alloc] initWithString:@"ios账号登录" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: KSCHEIGHT(15)],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];
//
//    iosZHlabel.attributedText = iosZhstring;
//
//    UIButton *iosZHBtn = [[UIButton alloc] init];
//    iosZHBtn.backgroundColor = [UIColor colorWithRed:172/255.0 green:95/255.0 blue:251/255.0 alpha:1.0];
//    iosZHBtn.layer.shadowColor = [UIColor colorWithRed:173/255.0 green:172/255.0 blue:172/255.0 alpha:0.14].CGColor;
//    iosZHBtn.layer.shadowOffset = CGSizeMake(0,2);
//    iosZHBtn.layer.shadowOpacity = 1;
//    iosZHBtn.layer.shadowRadius = 4;
//
//    [iosZHBtn addTarget:self action:@selector(iosZHBClick) forControlEvents:UIControlEventTouchUpInside];
//    CAGradientLayer *glT = [CAGradientLayer layer];
//    glT.frame = CGRectMake(0,0,kSCRATIO(250),KSCHEIGHT(40));
//    glT.startPoint = CGPointMake(0, 0);
//    glT.endPoint = CGPointMake(1, 1);
//    glT.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
//    glT.locations = @[@(0.0),@(1.0)];
//    ViewRadius(iosZHBtn, kSCRATIO(20));
//
//    [iosZHBtn.layer addSublayer:glT];
//    [iosZHBtn addSubview:iosZHlabel];
//    [self.view addSubview:iosZHBtn];
    
    //协议文字
    UILabel *Xylabel = [[UILabel alloc] init];
    Xylabel.numberOfLines = 0;
    NSMutableAttributedString *Xystring = [[NSMutableAttributedString alloc] initWithString:@"注册登录代表已同意                   和                   " attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(12)],NSForegroundColorAttributeName: [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]}];

    [Xystring addAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(12)]} range:NSMakeRange(0, 9)];

    [Xystring addAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(12)], NSForegroundColorAttributeName: [UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]} range:NSMakeRange(9, 6)];

    [Xystring addAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: kSCRATIO(12)]} range:NSMakeRange(15, 1)];

//    [Xystring addAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 12], NSForegroundColorAttributeName: [UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]} range:NSMakeRange(16, 7)];

    Xylabel.attributedText = Xystring;
    [self.view addSubview:Xylabel];
    
    //协议点击btn
    UIButton *XYTouchOBtn = [[UIButton alloc] init];
    [XYTouchOBtn addTarget:self action:@selector(XYTouchOclick) forControlEvents:UIControlEventTouchUpInside];
    [XYTouchOBtn setTitle:@"《服务协议》" forState:UIControlStateNormal];
    [XYTouchOBtn setTitleColor:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0] forState:UIControlStateNormal];
    XYTouchOBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:kSCRATIO(12)];
    [self.view addSubview:XYTouchOBtn];
    
    
    //协议点击btn2
    UIButton *XYTouchTBtn = [[UIButton alloc] init];
    [XYTouchTBtn addTarget:self action:@selector(XYTouchTclick) forControlEvents:UIControlEventTouchUpInside];
    [XYTouchTBtn setTitle:@"《隐私条款》" forState:UIControlStateNormal];
    [XYTouchTBtn setTitleColor:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0] forState:UIControlStateNormal];
    XYTouchTBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:kSCRATIO(12)];
    [self.view addSubview:XYTouchTBtn];
    
    
    
    [TouImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view.mas_top).mas_equalTo(KSCHEIGHT(100));
        make.width.height.mas_equalTo(kSCRATIO(115));
    }];
    [jslabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.bottom.mas_equalTo(TouImageV.mas_bottom).mas_equalTo(KSCHEIGHT(40));
        
    }];
    [NumberBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.bottom.mas_equalTo(jslabel.mas_bottom).mas_equalTo(KSCHEIGHT(80));
        make.width.mas_equalTo(kSCRATIO(250));
        make.height.mas_equalTo(KSCHEIGHT(40));
    }];
    [Nmuberlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(NumberBtn);
        make.centerY.mas_equalTo(NumberBtn);
        
    }];
//    [iosZHBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.view);
//        make.bottom.mas_equalTo(NumberBtn.mas_bottom).mas_equalTo(KSCHEIGHT(60));
//        make.width.mas_equalTo(kSCRATIO(250));
//        make.height.mas_equalTo(KSCHEIGHT(40));
//    }];
//    [iosZHlabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(iosZHBtn);
//        make.centerY.mas_equalTo(iosZHBtn);
//        
//    }];
    [Xylabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.bottom.mas_equalTo(self.view.mas_bottom).mas_equalTo(KSCHEIGHT(-64));
        
    }];
    [XYTouchOBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Xylabel.mas_left).mas_equalTo(kSCRATIO(110));
//        make.bottom.mas_equalTo(Xylabel).mas_equalTo(KSCHEIGHT(5));
        
        make.bottom.mas_equalTo(self.view.mas_bottom).mas_equalTo(KSCHEIGHT(-58));
    }];
    [XYTouchTBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Xylabel.mas_left).mas_equalTo(kSCRATIO(200));
//        make.bottom.mas_equalTo(Xylabel).mas_equalTo(KSCHEIGHT(5));
        make.bottom.mas_equalTo(self.view.mas_bottom).mas_equalTo(KSCHEIGHT(-58));
    }];
    
}
//手机号点击事件
-(void)numberBClick{
    phoenDViewController *loginNV = [[phoenDViewController alloc] init];
//    [self.navigationController pushViewController:loginNV animated:YES];
    loginNV.modalPresentationStyle = 0;
    [self.navigationController presentViewController:loginNV animated:NO completion:^{

    }];
}
//iOS账号点击事件
-(void)iosZHBClick{
    
}
//协议点击事件1
-(void)XYTouchOclick{
    XyViewController *xyConTV = [[XyViewController alloc] init];
    [self.navigationController pushViewController:xyConTV animated:NO];
//    xyConTV.modalPresentationStyle = 0;
//    [self.navigationController presentViewController:xyConTV animated:NO completion:^{
//
//    }];
}
//协议点击事件2
-(void)XYTouchTclick{
    YSViewController *ysConTV = [[YSViewController alloc] init];
    [self.navigationController pushViewController:ysConTV animated:NO];
//        ysConTV.modalPresentationStyle = 0;
//        [self.navigationController presentViewController:ysConTV animated:NO completion:^{
//
//        }];
}


@end
